package org.openmore.consumer.service.feign;

import io.swagger.annotations.ApiParam;
import org.openmore.consumer.dto.common.BaseResponse;
import org.openmore.consumer.service.feignImpl.OperatorLogServiceImpl;
import org.openmore.consumer.service.feignImpl.RoleServiceImpl;
import org.openmore.consumer.dto.common.OperateLogDto;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

import static org.springframework.http.MediaType.APPLICATION_JSON_UTF8_VALUE;

@Service
@FeignClient(value = "openmore-opc", fallbackFactory = OperatorLogServiceImpl.class)
public interface OperatorLogService {

    /**查询日志*/
    @RequestMapping(method = RequestMethod.GET, value = "/api/operateLog/query")
    public BaseResponse selectAllByPage(@RequestParam(required = false, defaultValue = "0") @ApiParam(value = "操作人姓名") String name,
                                        @RequestParam(required = false, defaultValue = "0") @ApiParam(value = "开始时间") Date startTime,
                                        @RequestParam(required = false, defaultValue = "0") @ApiParam(value = "结束时间") Date endTime,
                                        @RequestParam(required = false, defaultValue = "0") @ApiParam(value = "分页第几页") Integer pageNum,
                                        @RequestParam(required = false, defaultValue = "0") @ApiParam(value = "每页多少记录") Integer pageSize);
    /**查询日志*/
    @RequestMapping(method = RequestMethod.GET, value = "/api/operateLog/search")
    public BaseResponse searchOperate(@RequestParam(required = false) @ApiParam(value = "员工用户名") String staffName,
                                      @RequestParam(required = false) @ApiParam(value = "时间左边界 ") Date startTime,
                                      @RequestParam(required = false) @ApiParam(value = "时间右边界 ") Date endTime,
                                      @RequestParam(required = false, defaultValue = "1") @ApiParam(value = "分页第几页") Integer pageNum,
                                      @RequestParam(required = false, defaultValue = "10") @ApiParam(value = "每页多少记录") Integer pageSize);
    /**根据ID查询日志*/
    @RequestMapping(method = RequestMethod.GET, value = "/api/operateLog/{id}")
    public BaseResponse getOperateLogById(@PathVariable @ApiParam(required = true, value = "id") String id);
    /**添加日志*/
    @RequestMapping(method = RequestMethod.POST, value = "/api/operateLog/", consumes = {APPLICATION_JSON_UTF8_VALUE})
    public BaseResponse insertLog(@RequestBody @ApiParam(value = "日志信息") OperateLogDto operateLogDto);
}
